package Extends.CUICompents.CCanvas
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.events.Event;
	
	import mx.core.UIComponent;
	
	import Extends.CLoader.LoadManager;
	
	public class CMUICanvas extends UIComponent
	{
		protected var ms_backImage:Bitmap = new Bitmap();
		public function CMUICanvas()
		{
			super();
			this.addChild(ms_backImage);
		}
		
		protected function resize(w:Number,h:Number):void
		{
			this.graphics.lineStyle(1,0,0);
			this.graphics.drawRect(0,0,w,h);
		}
		public function set bitData(value:BitmapData):void
		{
			ms_backImage.bitmapData = value;
			this.resize(ms_backImage.width,ms_backImage.height);
		}
		
		public function set backBmp(value:Bitmap):void
		{
			ms_backImage.bitmapData = value.bitmapData;
			this.resize(ms_backImage.width,ms_backImage.height);
		}
		
		public function set backBmpSrc(value:String):void
		{
			LoadManager.LoadSource(value, onLoadBackBmpEnd, null);
		}
		
		private function onLoadBackBmpEnd(evt:Event):void
		{
			this.backBmp = Bitmap(evt.target.content);
		}
		override public function get width():Number
		{
			return ms_backImage.width;
		}
		
		override public function get height():Number
		{
			return ms_backImage.height;
		}
		
	}
}